<?php

namespace App\Admin\Models;

use App\Admin\Traits\staticMaps;
use Illuminate\Database\Eloquent\Model;

class Price extends Model
{
    use staticMaps;
    
    public function __construct()
    {
        parent::__construct();
    
        $this->setTable('config_price');
    }
    
    public static function getOtherPrice()
    {
        $other_price = static::getPartitionPrice()->get(1)->toArray();
        return array_combine($other_price, $other_price);
    }
    
    public static function getNumberPrice()
    {
        $number_price = static::getPartitionPrice()->get(0)->toArray();
        return array_combine($number_price, $number_price);
    }
    
    public static function getPartitionPrice()
    {
        return static::pluck('name')->partition(function ($v) {
            return preg_match('/^\d+$/', $v);
        });
    }
}
